#ifndef UPDOWNWIDGET_H
#define UPDOWNWIDGET_H

#include <QWidget>
#include <QPainter>
#include <QPaintEvent>
#include "core/account.h"

class UpDownWidget : public QWidget, public AccountListener
{
    Q_OBJECT
public:
    UpDownWidget(QWidget *pParent = 0);
    void onAccountChanged();

protected:
    virtual void paintEvent(QPaintEvent* event);
    virtual void mousePressEvent(QMouseEvent *event);
    void drawLines(QPainter &paint);
    void drawUpDown(QPainter &paint);
    void setupPara();
    int mouseToIndex(int pos);
    inline double getWidth(int i) const { return m_leftSpace + i * m_space; }
    inline double getHeight(double val) const{
        return m_bottomSpace + (val - m_minVal) / (m_maxVal - m_minVal) * (height() - m_bottomSpace);
    }

    double m_space;
    double m_maxVal;
    double m_minVal;
    int m_leftSpace;
    int m_rightSpace;
    int m_bottomSpace;
};

#endif // UPDOWNWIDGET_H